package com.xqboss.apps.domain.nft;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xqboss.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.stream.Stream;

/**
 * PrizeGift对象
 *
 * @author Administrator
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("prize_gift")
public class PrizeGift extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private Long id;

    @ApiModelProperty(value = "奖品ID")
    private Long prizeId;

    @ApiModelProperty(value = "奖品类型 1藏品 2玉珠 3天珠 4灵珠 5金核 6木核 7水核 8火核 9土核")
    @JsonIgnore
    private Integer prizeType;

    @ApiModelProperty(value = "奖品类型 1藏品 2玉珠 3天珠 4灵珠 5金核 6木核 7水核 8火核 9土核")
    @TableField(exist = false)
    private Integer integralType;

    @ApiModelProperty(value = "是否传了这个值")
    @TableField(exist = false)
    private Boolean isShow;

    @ApiModelProperty(value = "关联ID")
    @JsonIgnore
    private Long relateId;

    @ApiModelProperty(value = "关联ID类型 1藏品 2玉珠 3天珠 4灵珠 5金核 6木核 7水核 8火核 9土核")
    @JsonIgnore
    private Integer relateType;

    @ApiModelProperty(value = "发放数量")
    private Integer grantNum;

    @ApiModelProperty(value = "奖品名称")
    @TableField(exist = false)
    private String prizeTitle;

    @ApiModelProperty(value = "奖品图片")
    @TableField(exist = false)
    private String prizeImg;

    @ApiModelProperty(value = "奖品活动库存")
    @TableField(exist = false)
    private Integer prizeExtraStock;


    public enum PrizeTypeEnum {
        NFT(1, "藏品"),
        INTEGRAL(2, "龙蛋"),  // 玉珠
        jindou(3, "龙魂"),    // 天珠
        energy(4, "龙精"),    // 灵珠
        METALS(5, "金核"),
        TREE(6, "木核"),
        WATER(7, "水核"),
        FIRE(8, "火核"),
        SOIL(9, "土核");


        private int value;

        private String description;

        PrizeTypeEnum(int value, String description) {
            this.value = value;
            this.description = description;
        }

        public int getValue() {
            return value;
        }

        public String getDescription() {
            return description;
        }

        public void setValue(int value) {
            this.value = value;
        }


        public static PrizeGift.PrizeTypeEnum toLevel(int value) {
            return Stream.of(PrizeGift.PrizeTypeEnum.values())
                    .filter(c -> c.value == value)
                    .findAny()
                    .orElse(null);
        }
    }
}
